home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.5)
-
- '''Support for licensing in Miro-consumed feeds.'''
- from gtcache import gettext as _
- import rdfa
- DC_TITLE = 'http://purl.org/dc/elements/1.1/title'
-
- class DictSink(object):
- '''Simple sink for the RDFa parser; stores triples in a nested dict
- structure. After parsing self[subject][predicate] contains a list
- of objects.'''
-
- def __init__(self):
- self.data = { }
-
-
- def triple(self, s, p, o):
- self.data.setdefault(s, { }).setdefault(p, []).append(o)
-
-
-
- def license_name(license_uri):
- '''Attempt to determine the license name from the URI; if the name cannot
- be determined, the URI is returned unchanged.'''
-
- try:
- sink = rdfa.parseURI(license_uri, sink = DictSink())
- license_name = sink.data.get(license_uri, sink.data[u''])[DC_TITLE][0].strip()
- return license_name[1:license_name.find('"', 1)]
- except (IOError, KeyError):
- e = None
- return _('license page')
-
-
-